package br.com.cong.dao.util;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.AnnotationConfiguration;

public class HibernateUtility {

	private static SessionFactory factory;

	private static SessionFactory getSessionFactory() {
		if (factory == null) {
			AnnotationConfiguration configuration = new AnnotationConfiguration();
			configuration.configure();
			factory = configuration.buildSessionFactory();
		}
		return factory;
	}

	public static Session getSession() {
		return getSessionFactory().openSession();
	}
}
